#ifndef UTIL_HPP
#define UTIL_HPP

#include <iostream>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <string>
#include <ctime>
#include <cmath>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <malloc.h>

#include <CL/opencl.h>

#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#include <linux/limits.h>
#endif

#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
#define _aligned_malloc __mingw_aligned_malloc 
#define _aligned_free  __mingw_aligned_free 
#endif // __MINGW32__  and __MINGW64_VERSION_MAJOR


#ifndef _WIN32
#if defined(__INTEL_COMPILER)
#pragma warning(disable : 1125)
#endif
#endif

#define SDK_SUCCESS 0
#define SDK_FAILURE 1
#define SDK_EXPECTED_FAILURE 2

template<typename T>
const char* getOpenCLErrorCodeStr(T input);

struct Timer
{
    std::string name;
    long long _freq;
    long long _clocks;
    long long _start;
};

class Util
{
private:
    std::vector<Timer*> _timers;

public:
	Util(void);
	~Util(void);

	/// Helpers
public:
	bool fileToString(std::string &file, std::string &str, size_t& size);
	void error(const char* errorMsg) const;	
    void error(std::string errorMsg) const;

	/// Timing 
public:
    int createTimer();
    int resetTimer(int handle);
    int startTimer(int handle);
    int stopTimer(int handle);
    double readTimer(int handle);
};
#endif // UTIL_HPP

